package com.xy.tool.util;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * @author Greekn Zhang
 * @date 2021/7/2 18:09
 * @description
 */
@Component
public class FileUtils {

    private static String path;

    @Value("${file.path}")
    public void setPath(String path) {
        FileUtils.path = path;
    }

    /**
     * 将生成的台账临时文件暂存到此处
     */
    public static String getPath() {
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        return path;
    }

    /**
     * 将生成的台账临时文件删除
     */
    public static void delPath(String dPath) {
        File file = new File(path + dPath);
        if (file.exists()) {
            file.delete();
        }
    }
}
